<select class="form-control" name="province" id="J_province"></select>
<select class="form-control"  name="city" id="J_city" style="display:none;"></select>
<select class="form-control"  name="district" id="J_district" style="display:none;"></select>
<select class="form-control"  name="community" id="J_community" style="display:none;"></select>

<script type="text/javascript">


$(function(){

	var pid=<if condition="$param.province neq ''">{$param.province}<else />0</if>;  //默认省份id
	var cid=<if condition="$param.city neq ''">{$param.city}<else />0</if>;  //默认城市id
	var did=<if condition="$param.district neq ''">{$param.district}<else />0</if>;  //默认区县市id
	var coid=<if condition="$param.community neq ''">{$param.community}<else />0</if>;  //默认乡镇id

    /*修复联动不及时的bug，陈一枭*/
function change_province(pid){
        $.post("{:addons_url('ChinaCity://ChinaCity/getProvince')}", {pid: pid}, function(result){
            $("#J_province").html(result);
        });
    }

function change_city(p_pid,p_cid){
    $.post('{:addons_url("ChinaCity://ChinaCity/getCity")}', {pid: p_pid, cid: p_cid}, function(result){
        $("#J_city").show().html(result);
    });
    var cid_g=$(this).children('option:selected').val();
    change_district(cid_g)
}
function change_district(p_cid,p_did){
    $.post('{:addons_url("ChinaCity://ChinaCity/getDistrict")}', {cid: p_cid, did: p_did}, function(result){
        $("#J_district").show().html(result);
    });
    var did_g=$(this).children('option:selected').val();
    change_community(did_g)
}
	function change_community(p_did,p_coid){
        $.post('{:addons_url("ChinaCity://ChinaCity/getCommunity")}', {did: p_did, coid: p_coid}, function(result){
            $("#J_community").show().html(result);
        });
    }

    change_province(pid);
    change_city(pid,cid);
    change_district(cid,did);
    change_community(did,coid);



	$('#J_province').change(function(){
		var pid_g=$(this).children('option:selected').val();
		change_city(pid_g)


	});

	$('#J_city').change(function(){
		var cid_g=$(this).children('option:selected').val();
		change_district(cid_g)


	});

	$('#J_district').change(function(){
		var did_g=$(this).children('option:selected').val();
	change_community(did_g)
	});

});
/*修复联动不及时的bug，陈一枭end*/
</script>